#include "../unp.h"

/**
 * gcc -g -o tcpcli01 tcpcli01.c ../lib/error.o ../lib/wrapsock.o ../lib/wrapunix.o ../lib/wraplib.o ../lib/str_cli.o ../lib/wrapstdio.o ../03/writen.o ../03/readn.o ../03/readline.o
 */

int
main(int argc, char **argv)
{
    int sockfd;
    struct sockaddr_in servaddr;
    if(argc !=2)
    {
        err_quit("usage: tcpcli01 <IPaddress>");
    }
    sockfd = Socket(AF_INET, SOCK_STREAM, 0);
    bzero(&servaddr, sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_port = htons(SERV_PORT);
    Inet_pton(AF_INET, argv[1], &servaddr.sin_addr);
    Connect(sockfd,(SA*) &servaddr, sizeof(servaddr));
    str_cli(stdin,sockfd);
    exit(0);
}